package com.geen.tuoke.ui.popupwindow

import android.content.Context
import android.view.View
import androidx.databinding.DataBindingUtil
import com.geen.tuoke.R
import com.geen.tuoke.databinding.PopupTaskPhoneBinding
import com.geen.tuoke.utils.ext.dp2px
import com.geen.tuoke.widget.popupwindow.EasyPopup
import com.qmuiteam.qmui.kotlin.onClick

/**
 * @author 文庆
 * @description 任务-号码功能弹窗
 */
class TaskPhonePopup @JvmOverloads constructor(
    context: Context,
    var onEdit: () -> Unit,
    var onDelete: () -> Unit,
    var onLook: () -> Unit
) : EasyPopup(context) {

    var binding: PopupTaskPhoneBinding? = null

    override fun onPopupWindowCreated() {
        super.onPopupWindowCreated()
        setContentView<EasyPopup>(R.layout.popup_task_phone)

        setWidth<EasyPopup>(dp2px(250f))
            .setFocusAndOutsideEnable<EasyPopup>(true)
            .setHeight<EasyPopup>(dp2px(50f))
    }


    override fun onPopupWindowViewCreated(contentView: View) {
        super.onPopupWindowViewCreated(contentView)
        binding = DataBindingUtil.bind(contentView)

        binding?.run {

            tvEdit.onClick {
                dismiss()
                onEdit()
            }
            tvDelete.onClick {
                dismiss()
                onDelete()
            }
            tvLook.onClick {
                dismiss()
                onLook()
            }

        }
    }
}